package com.songlanyun.common.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonValue;
import com.songlanyun.common.drive.IntegerEnum;

import java.util.Objects;

public class PrivateMessageConstant {

    /**
     * 消息类型
     * 0：活动消息
     * 1：支付消息
     * 2：物流消息
     * 3：售后消息
     * 4：互动消息
     */
    @JsonFormat(shape = JsonFormat.Shape.OBJECT)
    public static enum MessageType implements IntegerEnum<Integer> {

        ACTIVITY_MESSAGE(0, "活动消息"),
        PAY_MESSAGE(1, "支付消息"),
        LOGISTICS_MESSAGE(2, "物流消息"),
        RIGHTS_MESSAGE(3, "售后消息"),
        INTERACTION_MESSAGE(4, "互动消息"),
        SYSTEM_MESSAGES(5, "系统消息"),
        ;

        @EnumValue
        @JsonValue
        private Integer code;

        private String msg;

        MessageType(Integer code, String msg) {
            this.code = code;
            this.msg = msg;
        }

        public void setCode(Integer code) {
            this.code = code;
        }

        public String getMsg() {
            return msg;
        }

        public void setMsg(String msg) {
            this.msg = msg;
        }

        @Override
        public Integer getCode() {
            return code;
        }

        @JsonCreator
        public static MessageType getByCode(int code) {
            for (MessageType value : MessageType.values()) {
                if (Objects.equals(code, value.getCode())) {
                    return value;
                }
            }
            return null;
        }
    }

    /**
     * 模型类型
     * 0：秒杀活动
     * 1：拼团活动
     * <p>
     * 2：支付成功
     * <p>
     * 3：已发货
     * 4：已收货
     * <p>
     * 5：售后
     * <p>
     * 6：文章点赞、分享、评论
     * 7：关注
     * 8：审核
     */
    @JsonFormat(shape = JsonFormat.Shape.OBJECT)
    public static enum ModelType implements IntegerEnum<Integer> {

        SECKILL(0, "秒杀活动"),
        GROUP_BUY(1, "拼团活动"),
        REFILL_PAY_SUCCESS(2, "转入卡支付成功"),
        ORDER_PAY_SUCCESS(3, "支付成功"),
        LOGISTICS(4, "物流"),
        REFUND(5, "售后"),
        OPUS_LIKE_SHARE_COMMENT(6, "文章点赞、分享、评论"),
        CONCERNS(7, "关注"),
        CHECK(8, "审核"),
        CARRIER_AUDIT(9, "区县运营商审核"),
        ;

        @EnumValue
        @JsonValue
        private Integer code;

        private String msg;

        ModelType(Integer code, String msg) {
            this.code = code;
            this.msg = msg;
        }

        public void setCode(Integer code) {
            this.code = code;
        }

        public String getMsg() {
            return msg;
        }

        public void setMsg(String msg) {
            this.msg = msg;
        }

        @Override
        public Integer getCode() {
            return code;
        }

        @JsonCreator
        public static ModelType getByCode(int code) {
            for (ModelType value : ModelType.values()) {
                if (Objects.equals(code, value.getCode())) {
                    return value;
                }
            }
            return null;
        }
    }

    /**
     * 售后状态
     * 0：商家同意维权，待买家发货
     * 1：商家拒绝维权
     * 2：商家已收货
     * 3：商家已退款
     */
    @JsonFormat(shape = JsonFormat.Shape.OBJECT)
    public static enum RightsStatus implements IntegerEnum<Integer> {

        AGREE(0, "商家同意维权，等待买家发货"),
        REFUSE(1, "商家拒绝维权"),
        RECEIPT(2, "商家已收货"),
        REFUND(3, "商家已退款"),
        ;

        @EnumValue
        @JsonValue
        private Integer code;

        private String msg;

        RightsStatus(Integer code, String msg) {
            this.code = code;
            this.msg = msg;
        }

        public void setCode(Integer code) {
            this.code = code;
        }

        public String getMsg() {
            return msg;
        }

        public void setMsg(String msg) {
            this.msg = msg;
        }

        @Override
        public Integer getCode() {
            return code;
        }

        @JsonCreator
        public static RightsStatus getByCode(int code) {
            for (RightsStatus value : RightsStatus.values()) {
                if (Objects.equals(code, value.getCode())) {
                    return value;
                }
            }
            return null;
        }
    }
}
